<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8"/>
	<title>控制台 | 远程播放RemotePlayer</title>
	<meta name="Robots" content="NOINDEX, NOFOLLOW, NOARCHIVE"/>
	<meta name="ViewPort" content="initial-scale=1, minimum-scale=1, width=device-width"/>
	<style type="text/css">
		::selection { background: rgba(78, 176, 248, 0.3); }
		html, body { width: 100%; height: 100%; cursor: default; }
		html, body, p, h2, div { margin: 0; padding: 0; }
		body {     background: rgb(255, 165, 0); text-align: center; user-select: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; }
		html { font: 12px "Segoe UI", "Microsoft YaHei", FreeSans, Arimo, "Droid Sans", "Hiragino Sans GB", "Hiragino Sans GB W3", Arial, sans-serif; }
		h2 { margin-bottom: 25px; font-size: 30px; font-weight: 300; color: #e05d6f; }
		p { line-height: 1.5em; font-size: 12px; color: #95a2a9; margin-bottom: 5px; }
		.title { position: relative; top: 75px; margin-bottom: .7em; line-height: 30px; font-size: 26px; font-weight: 300; color: #fff; text-shadow: 0 0 4px #666666; }
		.box { position: relative; top: 80px; width: 600px; height:250px; max-width: 85%; margin: 0 auto; background: #fff; padding: 15px;   box-shadow: 0 0 50px #514901; }
		.main { font-size: 18px; color: #000; font-weight: 500; line-height: 1.7em; margin: 0 0 10px; }
		.foot { position: relative; top: 80px; margin: 15px 15px 0; font-size: 12px;   color: #815400; }
		pre {   background: #D8C500; color: #ffffff; padding: 15px 20px; margin: 25px -15px -15px; line-height: 1.4em; font-size: 14px; text-align: left; word-break: break-all; white-space: pre-wrap; }
		.main, pre { user-select: text; -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; cursor: text; }
		#popup{  height: 42px;
  background-color: rgba(0, 0, 0, 0.27);
  color: white;
  font-size: 26px;
  position: fixed;
  width: 100%;
display: none;}
#bott{  margin: 0 auto;
  text-align: center;
  position: absolute;
  bottom: 25px;
  width: inherit;}
  #playlist {
  background: rgba(0, 0, 0, 0.5);
  width: 470px;
  margin: 0 auto 50px;
  padding: 10px 15px;
  list-style: none;
  /* float: right; */
  position: fixed;
  left: 10px;
  bottom: 10px;
  -moz-border-radius: 5px;
  -webkit-border-radius: 5px;
  -o-border-radius: 5px;
  -ms-border-radius: 5px;
  -khtml-border-radius: 5px;
  border-radius: 5px;
  -moz-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  -webkit-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  -o-box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
#playlist li {
  color: #aaa;
  font-size: 12px;
  line-height: 2;
  padding-left: 25px;
  cursor: pointer;
  text-overflow: ellipsis;
  -moz-transition: 0.3s;
  -webkit-transition: 0.3s;
  -o-transition: 0.3s;
  transition: 0.3s;
}
#playlist li:hover {
  color: #fff;
}
#playlist li.playing {
  background: url(/css/images/playing.png) no-repeat 0 center;
  color: #fff;
  font-weight: bold;
}
		pre::selection { background: rgba(255, 255, 255, 0.99); color: #3498DB; }
	</style>
</head>
<body>
	<div id="popup">通知文本</div>
<p class="title">远程播放RemotePlayer</p>
<div class="box">
	<div id="before">
	<h2><b>输入播放台编号</b> {{code}}</h2>
	<p class="main selectable">
	
		<input type="text" id="cid-in">
		<button id="cid-submit">提交</button>
	
	</p>
	</div>
	<div id="OK" style="display:none;"><h2><b>播放台编号：<span id="cid-show"></span></b> {{code}}</h2>
	<p class="main selectable">
		 <button id="namesearch">通过歌名搜索并添加</button> <br>
		 <input type="text" id="sid-in" placeholder="添加歌曲 网易云音乐id">
		<button id="sid-submit">提交</button> <br>
		 <button class="ctrl-submit" value="prv">上一曲</button>
		<button class="ctrl-submit" value="pp">播放/暂停</button>
		<button class="ctrl-submit" value="nxt">下一曲</button><br>
		<button class="ctrl-submit" value="dll">删除最近添加</button>
		<button class="ctrl-submit" value="vu">音量↑</button>
		<button class="ctrl-submit" value="vd">音量↓</button>

		<ul id="playlist"></ul>

	
	</p></div>
	<p id="bott">感谢<a href="http://freejishu.com" target="_blank">freejishu</a>提供搜索接口</p>
	<if condition="">
	</if>
</div>
<p class="foot">Powered by Node.js | 沪ICP备15000548号-4 | <a href="http://u.cdog.me">CDog站点联盟</a></p>
<script src="http://libs.useso.com/js/jquery/2.1.1/jquery.min.js"></script>
<script>
	function popup(text){
		var p= $("#popup");
		p.html(text);
		p.fadeIn(700);
		setTimeout(function(){
			p.fadeOut(700);
		},3000);
	}
	$(function(){
		$("#cid-submit").click(function(){
			var param={cid:$("#cid-in").val()};
			$.ajax({
				type: "get",
				url: "/vaildclient",
				dataType:"json",
				data:param,
				success: function(obj){
					if (obj.code==200){
						cid=$("#cid-in").val();
						$("#before").fadeOut(700,function(){
							$("#OK").fadeIn(700);
						});
						
						$("#cid-show").html(cid);
						synclist();
						setInterval("synclist()",5000);
					}
					popup(obj.message);
				}
			});
		});
		$(".ctrl-submit").click(function(evt){
			var param={cid:cid,"do":$(evt.target).val()};
			$.ajax({
				type: "get",
				url: "/clientdo",
				dataType:"json",
				data:param,
				success: function(obj){
					popup(obj.message);
					if ((param.do!="vu")&&(param.do!="vd")){
						synclist();
					}
				}
			});
		});

		$("#sid-submit").click(function(evt){
			var param={sid: $("#sid-in").val(),cid:cid};
			$.ajax({
				type: "get",
				url: "/add",
				dataType:"json",
				data:param,
				success: function(rsong){
					popup(rsong.message);
					$("#sid-in").val("");
					synclist();
				}
			});
		});

		synclist=function(evt){
			var param={cid:cid};
			$.ajax({
				type: "get",
				url: "/list",
				dataType:"json",
				data:param,
				success: function(obj){
					var plist=$("#playlist");
					plist.empty();
					for (i in obj.list){
						plist.append('<li>'+obj.list[i].artist+' - '+obj.list[i].title+'</li>');
						$('#playlist li').removeClass('playing').eq(obj.current).addClass('playing');
					}
				}
			});
		}

		$("#namesearch").click(function(){
			var address="http://"+document.location.host+"/add";
			go="http://v.freejishu.com?cid="+cid+"&cbk="+encodeURIComponent(address)+"/";
			window.open(go);
			
		});

	});
</script>
</body>

</html>
